﻿
using Xacml.Core;
using Xacml.Core.Policy;
using System;
using System.Xml;

namespace Xacml.Core.Context
{
  public class AttributeValueElementReadWrite : StringValueBase
  {
    private string _contents;

    public virtual string Contents
    {
      get
      {
        return this._contents;
      }
      set
      {
        this._contents = value;
      }
    }

    public override string Value
    {
      get
      {
        return this._contents;
      }
      set
      {
        this._contents = value;
      }
    }

    public override string DataTypeValue
    {
      get
      {
        return (string) null;
      }
      set
      {
      }
    }

    public override bool IsReadOnly
    {
      get
      {
        return false;
      }
    }

    public AttributeValueElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
      : base(XacmlSchema.Context, schemaVersion)
    {
      if (reader.LocalName == "AttributeValue" && this.ValidateSchema(reader, schemaVersion))
        this._contents = reader.ReadInnerXml();
      else
        throw new Exception(Resource.ResourceManager[Resource.MessageKey.exc_invalid_node_name, new object[1]
        {
          (object) reader.LocalName
        }]);
    }

    public AttributeValueElementReadWrite(string value, XacmlVersion schemaVersion)
      : base(XacmlSchema.Context, schemaVersion)
    {
      this._contents = value;
    }

    public AttributeValueElementReadWrite(AttributeValueElementReadWrite attributeValueElement)
      : base(XacmlSchema.Context, attributeValueElement.SchemaVersion)
    {
      this._contents = attributeValueElement._contents;
    }
  }
}
